package com.example.epidemic_assistant;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

import com.example.epidemic_assistant.ui.LoginActivity;

public class WelcomeActivity extends BaseActivity {

    private boolean mAutoLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        SharedPreferences sharedPreferences = getSharedPreferences("autoLogin", MODE_PRIVATE);
        mAutoLogin = sharedPreferences.getBoolean("autoLogin", false);
        Thread thread = new Thread() {
            @Override
            public void run() {
                try {
                    sleep(3000);
                    if (mAutoLogin) {
                        startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                    } else {
                        startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
                    }
                    finish();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        thread.start();
    }
}